
#include <gtk/gtk.h>
#include "mainwindow.h"
#include "chat.h"
/*
typedef struct MyMsgUser_T {
	gchar	*photo;		// 1.gif
	gchar	*nick;
	gchar	*username;
	gchar	*hostname;
	gchar	*macAddr;
	gchar	*signature;
	gint	*status;
} MyMsgUser;

typedef struct UserInfo_T {
	gchar	*macAddr;
	gint	*groupID;
	gchar	*markname;
	UserGroup	*pUserGroup;
	gpointer iter;
} UserInfo;

typedef struct UserGroup_T {
	gint	groupID;
	gchar	*groupName;
	gint	gUserCnt;
	gpointer iter;
} UserGroup;
*/
GList *grouplist;

void buildTestData()
{
	UserGroup *group = g_malloc(sizeof(UserGroup));
	group -> groupID = 1;
	group -> groupName = "高中同学";
	group -> gUserCnt = 5;
	group -> iter = g_malloc(sizeof(GtkTreeIter));

	UserGroup *group1 = g_malloc(sizeof(UserGroup));
	group1 -> groupID = 2;
	group1 -> groupName = "初中同学";
	group1 -> gUserCnt = 15;
	group1 -> iter = g_malloc(sizeof(GtkTreeIter));
	grouplist = g_list_append(grouplist, group);
	grouplist = g_list_append(grouplist, group1);
}
int main_mainwin(int argc, char *argv[])
{
	GtkWidget *window;
	
	gtk_init(&argc,&argv); 
	window = createMainWindow(); 
	update_widget_bg(window,"../res/skin/bg3.jpg"); 
	gtk_widget_show_all(window);

	// 添加分组
	//addUserGroup(gpointer groupdata, gpointer data);
	buildTestData();
	initUserGroup(grouplist);

	MyMsgUser *user1 = g_malloc(sizeof(MyMsgUser));
	user1 -> photo = "4.gif";		// 1.gif
	user1 -> nick = "I Like Fly";
	user1 -> username = "李非";
	user1 -> hostname = "PC555";
	user1 -> macAddr = "MAC:333";
	user1 -> ipAddr = "192.168.1.111";
	user1 -> signature = "人生就像一场履行！";
	user1 -> status = 1;
	user1 -> groupID = 1;
	user1 -> markname ="备注名";
	user1 -> pUserGroup = grouplist -> data;
	user1 -> iter = g_malloc(sizeof(GtkTreeIter));
/*
	UserInfo *info1 = g_malloc(sizeof(UserInfo));
	info1 -> macAddr = "";
	info1 -> groupID = 1;
	info1 -> markname ="bbbb";
	info1 -> pUserGroup = grouplist -> data;
	info1 -> iter = g_malloc(sizeof(GtkTreeIter));
*/
	// 添加好友
	addUser(user1);
	g_free(user1);
	
	gtk_main();
	
    return 0;  
}

int main_chatwin(int argc, char *argv[])
{
	GtkWidget *window;
	
	gtk_init(&argc,&argv);

	MyMsgUser *user1 = g_malloc(sizeof(MyMsgUser));
	user1 -> photo = "4.gif";		// 1.gif
	user1 -> nick = "I Like Fly";
	user1 -> username = "李非";
	user1 -> hostname = "PC555";
	user1 -> macAddr = "MAC:333";
	user1 -> ipAddr = "192.168.1.111";
	user1 -> signature = "人生就像一场履行！";
	user1 -> status = 1;
	user1 -> groupID = 1;
	user1 -> markname ="备注名";
	//user1 -> pUserGroup = grouplist -> data;
	user1 -> iter = g_malloc(sizeof(GtkTreeIter));

	g_printf("test...\n");
	window = createChatWindow(user1); 
	gtk_widget_show_all(window);
	gtk_main();
	return 0;
}
int main(int argc, char *argv[])
{
	//return main_mainwin(argc, argv);
	return main_chatwin(argc, argv);	
}
